package{
	import flash.display.Sprite;
	public class DrawObj extends Sprite{
		public function DrawObj(){
			addChild(drawRect(0,0,200,100,1,0xff0000,0x999999,0.6));
			//addChild(drawRoundRect(0,0,200,100,1,0xff0000,0x999999,0.6));
			//addChild(drawCircle(50,50,50,0x999999,1,0xff0000,0.6));
			//addChild(drawEllipse(0,0,200,100,0x999999,1,0xff0000,0.6));
		}
		/**
		 *绘制矩形 
		 * @param w 宽
		 * @param h 高
		 * @param border 边框大小
		 * @param borderColor 边框颜色
		 * @param backColor 填充颜色
		 * @param alpha 透明度
		 * @return 
		 * 
		 */		
		static public function drawRect(x:int,y:int,w:int,h:int,border:int=0,borderColor:uint=0x333333,backColor:uint=0x999999,alpha:Number=0.6):Sprite{
			var sp:Sprite=new Sprite();
			sp.graphics.beginFill(backColor,alpha);
			sp.graphics.drawRect(x,y,w,h);
			sp.graphics.endFill();
			if(border!=0){
				sp.graphics.lineStyle(border,borderColor,alpha);
				sp.graphics.drawRect(x,y,w,h);
			}
			return sp;
		}
		/**
		 * 绘制圆角矩形
		 * @param w 宽度
		 * @param h 高度
		 * @param border 边框大小
		 * @param borderColor 边框颜色
		 * @param backColor 填充颜色
		 * @param alpha 透明度
		 * @return 
		 * 
		 */		
		static public function drawRoundRect(x:int,y:int,w:int,h:int,border:int=0,borderColor:uint=0x333333,backColor:uint=0x999999,alpha:Number=0.6):Sprite{
			var sp:Sprite=new Sprite();
			sp.graphics.beginFill(backColor,alpha);
			sp.graphics.drawRoundRect(x,y,w,h,20,20);
			sp.graphics.endFill();
			if(border!=0){
				sp.graphics.lineStyle(border,borderColor,alpha);
				sp.graphics.drawRoundRect(x,y,w,h,20,20);
				sp.graphics.endFill();
			}
			return sp;
		}
		/**
		 *绘制圆 
		 * @param x 圆心坐标
		 * @param y 圆心坐标
		 * @param radius 半径
		 * @param color 填充颜色
		 * @param border 边框大小
		 * @param borderColor 边框颜色
		 * @param alpha 透明度
		 * @return 
		 * 
		 */		
		static public function drawCircle(x:int,y:int,radius:int,color:uint=0x333333,border:int=0,borderColor:uint=0x000000,alpha:Number=1):Sprite{
			var sp:Sprite=new Sprite();
			sp.graphics.beginFill(color,alpha);
			sp.graphics.drawCircle(x,y,radius);
			sp.graphics.endFill();
			if(border!=0){
				sp.graphics.lineStyle(border,borderColor,alpha);
				sp.graphics.drawCircle(x,y,radius);
			}
			return sp;
		}
		/**
		 *绘制椭圆 
		 * @param x 坐标
		 * @param y 坐标
		 * @param w 宽
		 * @param h 高
		 * @param color 颜色
		 * @param border 边框大小
		 * @param borderColor 边框颜色
		 * @param alpha 透明度
		 * @return 
		 * 
		 */		
		static public function drawEllipse(x:int,y:int,w:int,h:int,color:uint=0x333333,border:int=0,borderColor:uint=0x000000,alpha:Number=1):Sprite{
			var sp:Sprite=new Sprite();
			sp.graphics.beginFill(color,alpha);
			sp.graphics.drawEllipse(x,y,w,h);
			sp.graphics.endFill();
			if(border!=0){
				sp.graphics.lineStyle(border,borderColor,alpha);
				sp.graphics.drawEllipse(x,y,w,h);
			}
			return sp;
		}
	}
}